package dryven.unittest.mocks;

import java.lang.annotation.Annotation;
import java.lang.reflect.Method;

import dryven.model.di.AbstractDependencyService;
import dryven.model.di.DependencyService;
import dryven.model.di.LocalThreadStorage;

public class MockDependencyService extends AbstractDependencyService {

	@Override
	public <T> T constructObject(LocalThreadStorage storage, Class<T> type) {
		try {
			return type.newInstance();
		} catch (Exception e) {
			throw new RuntimeException(e);
		}
	}

	@Override
	public Object invokeMethod(LocalThreadStorage storage, Method m, Object o, Object[] existingParameters) {
		try {
			return m.invoke(o, existingParameters);
		} catch (Exception e) {
			throw new RuntimeException(e);
		}
	}

	@Override
	public Object getDependency(LocalThreadStorage storage, Class<?> type, Annotation[] annotations) {
		try {
			return type.newInstance();
		} catch (Exception e) {
			throw new RuntimeException(e);
		}
	}


}
